package com.wxtl.action.file;

import java.io.InputStream;
import java.net.URL;

import javax.servlet.ServletContext;

import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class DownloadAction extends ActionSupport {
	private String filename;
	private String revision;
	
	@Override
	public String execute() throws Exception {
		System.out.println("download:" + filename);
		return SUCCESS;
	}
	
	public String getFilename() {
        return filename;
    }
 
    public void setFilename(String filename) {
    	this.filename = filename;
    }
 
    public InputStream getFile() throws Exception {
    	ServletContext ctx = ServletActionContext.getServletContext();
    	return ctx.getResourceAsStream("/upload/" + filename);
    }

	public String getRevision() {
		return revision;
	}

	public void setRevision(String revision) {
		this.revision = revision;
	}
    
}